In [2]:
pip install pandas matplotlib seaborn numpy
Requirement already satisfied: pandas in c:\users\cheta\anaconda3\lib\site-packages (2.0.3)
Requirement already satisfied: matplotlib in c:\users\cheta\anaconda3\lib\site-packages (3.7.2)
Requirement already satisfied: seaborn in c:\users\cheta\anaconda3\lib\site-packages (0.12.2)
Requirement already satisfied: numpy in c:\users\cheta\anaconda3\lib\site-packages (1.24.3)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\cheta\anaconda3\lib\site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\cheta\anaconda3\lib\site-packages (from pandas) (2023.3.post1)
Requirement already satisfied: tzdata>=2022.1 in c:\users\cheta\anaconda3\lib\site-packages (from pandas) (2023.3)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (1.0.5)
Requirement already satisfied: cycler>=0.10 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (4.25.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (23.1)
Requirement already satisfied: pillow>=6.2.0 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (9.4.0)
Requirement already satisfied: pyparsing<3.1,>=2.3.1 in c:\users\cheta\anaconda3\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: six>=1.5 in c:\users\cheta\anaconda3\lib\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Note: you may need to restart the kernel to use updated packages.
In [4]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline


gd = pd.read_csv('GSDP.csv')
gd = pd.read_csv('GSDP.csv')

# Display first few rows to understand the structure of the data
gd.head(), gd.head()
Out[4]:
(                   Items  Description Duration  Andhra Pradesh   \
 0  GSDP - CURRENT PRICES (` in Crore)  2011-12         379402.0   
 1  GSDP - CURRENT PRICES (` in Crore)  2012-13         411404.0   
 2  GSDP - CURRENT PRICES (` in Crore)  2013-14         464272.0   
 3  GSDP - CURRENT PRICES (` in Crore)  2014-15         526468.0   
 4  GSDP - CURRENT PRICES (` in Crore)  2015-16         609934.0   
 
    Arunachal Pradesh     Assam     Bihar  Chhattisgarh      Goa   Gujarat  \
 0            11063.0  143175.0  247144.0      158074.0  42367.0  615606.0   
 1            12547.0  156864.0  282368.0      177511.0  38120.0  724495.0   
 2            14602.0  177745.0  317101.0      206690.0  35921.0  807623.0   
 3            16761.0  198098.0  373920.0      234982.0  40633.0  895027.0   
 4            18784.0  224234.0  413503.0      260776.0  45002.0  994316.0   
 
     Haryana  ...  Telangana  Tripura  Uttar Pradesh  Uttarakhand  \
 0  297539.0  ...   359433.0  19208.0       724049.0     115523.0   
 1  347032.0  ...   401493.0  21663.0       822903.0     131835.0   
 2  400662.0  ...   452186.0  25593.0       944146.0     149817.0   
 3  437462.0  ...   511178.0  29667.0      1043371.0     161985.0   
 4  485184.0  ...   575631.0      NaN      1153795.0     184091.0   
 
    West Bengal1  Andaman & Nicobar Islands  Chandigarh     Delhi  Puducherry  \
 0           NaN                     3979.0     18768.0  343767.0     16818.0   
 1           NaN                     4421.0     21609.0  391238.0     18875.0   
 2           NaN                     5159.0     24787.0  443783.0     21870.0   
 3           NaN                     5721.0     27844.0  492424.0     24089.0   
 4           NaN                        NaN     30304.0  551963.0     26533.0   
 
    All_India GDP  
 0      8736039.0  
 1      9946636.0  
 2     11236635.0  
 3     12433749.0  
 4     13675331.0  
 
 [5 rows x 36 columns],
                    Items  Description Duration  Andhra Pradesh   \
 0  GSDP - CURRENT PRICES (` in Crore)  2011-12         379402.0   
 1  GSDP - CURRENT PRICES (` in Crore)  2012-13         411404.0   
 2  GSDP - CURRENT PRICES (` in Crore)  2013-14         464272.0   
 3  GSDP - CURRENT PRICES (` in Crore)  2014-15         526468.0   
 4  GSDP - CURRENT PRICES (` in Crore)  2015-16         609934.0   
 
    Arunachal Pradesh     Assam     Bihar  Chhattisgarh      Goa   Gujarat  \
 0            11063.0  143175.0  247144.0      158074.0  42367.0  615606.0   
 1            12547.0  156864.0  282368.0      177511.0  38120.0  724495.0   
 2            14602.0  177745.0  317101.0      206690.0  35921.0  807623.0   
 3            16761.0  198098.0  373920.0      234982.0  40633.0  895027.0   
 4            18784.0  224234.0  413503.0      260776.0  45002.0  994316.0   
 
     Haryana  ...  Telangana  Tripura  Uttar Pradesh  Uttarakhand  \
 0  297539.0  ...   359433.0  19208.0       724049.0     115523.0   
 1  347032.0  ...   401493.0  21663.0       822903.0     131835.0   
 2  400662.0  ...   452186.0  25593.0       944146.0     149817.0   
 3  437462.0  ...   511178.0  29667.0      1043371.0     161985.0   
 4  485184.0  ...   575631.0      NaN      1153795.0     184091.0   
 
    West Bengal1  Andaman & Nicobar Islands  Chandigarh     Delhi  Puducherry  \
 0           NaN                     3979.0     18768.0  343767.0     16818.0   
 1           NaN                     4421.0     21609.0  391238.0     18875.0   
 2           NaN                     5159.0     24787.0  443783.0     21870.0   
 3           NaN                     5721.0     27844.0  492424.0     24089.0   
 4           NaN                        NaN     30304.0  551963.0     26533.0   
 
    All_India GDP  
 0      8736039.0  
 1      9946636.0  
 2     11236635.0  
 3     12433749.0  
 4     13675331.0  
 
 [5 rows x 36 columns])
In [5]:
gd = pd.read_csv('GSDP.csv')
gd.head()
Out[5]:
Items Description Duration Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat Haryana ... Telangana Tripura Uttar Pradesh Uttarakhand West Bengal1 Andaman & Nicobar Islands Chandigarh Delhi Puducherry All_India GDP
0 GSDP - CURRENT PRICES (` in Crore) 2011-12 379402.0 11063.0 143175.0 247144.0 158074.0 42367.0 615606.0 297539.0 ... 359433.0 19208.0 724049.0 115523.0 NaN 3979.0 18768.0 343767.0 16818.0 8736039.0
1 GSDP - CURRENT PRICES (` in Crore) 2012-13 411404.0 12547.0 156864.0 282368.0 177511.0 38120.0 724495.0 347032.0 ... 401493.0 21663.0 822903.0 131835.0 NaN 4421.0 21609.0 391238.0 18875.0 9946636.0
2 GSDP - CURRENT PRICES (` in Crore) 2013-14 464272.0 14602.0 177745.0 317101.0 206690.0 35921.0 807623.0 400662.0 ... 452186.0 25593.0 944146.0 149817.0 NaN 5159.0 24787.0 443783.0 21870.0 11236635.0
3 GSDP - CURRENT PRICES (` in Crore) 2014-15 526468.0 16761.0 198098.0 373920.0 234982.0 40633.0 895027.0 437462.0 ... 511178.0 29667.0 1043371.0 161985.0 NaN 5721.0 27844.0 492424.0 24089.0 12433749.0
4 GSDP - CURRENT PRICES (` in Crore) 2015-16 609934.0 18784.0 224234.0 413503.0 260776.0 45002.0 994316.0 485184.0 ... 575631.0 NaN 1153795.0 184091.0 NaN NaN 30304.0 551963.0 26533.0 13675331.0

5 rows × 36 columns

In [6]:
gd.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 11 entries, 0 to 10
Data columns (total 36 columns):
 #   Column                     Non-Null Count  Dtype  
---  ------                     --------------  -----  
 0   Items  Description         11 non-null     object 
 1   Duration                   11 non-null     object 
 2   Andhra Pradesh             11 non-null     float64
 3   Arunachal Pradesh          9 non-null      float64
 4   Assam                      9 non-null      float64
 5   Bihar                      9 non-null      float64
 6   Chhattisgarh               11 non-null     float64
 7   Goa                        9 non-null      float64
 8   Gujarat                    9 non-null      float64
 9   Haryana                    11 non-null     float64
 10  Himachal Pradesh           7 non-null      float64
 11  Jammu & Kashmir            9 non-null      float64
 12  Jharkhand                  9 non-null      float64
 13  Karnataka                  9 non-null      float64
 14  Kerala                     9 non-null      float64
 15  Madhya Pradesh             11 non-null     float64
 16  Maharashtra                7 non-null      float64
 17  Manipur                    7 non-null      float64
 18  Meghalaya                  11 non-null     float64
 19  Mizoram                    7 non-null      float64
 20  Nagaland                   7 non-null      float64
 21  Odisha                     11 non-null     float64
 22  Punjab                     7 non-null      float64
 23  Rajasthan                  7 non-null      float64
 24  Sikkim                     9 non-null      float64
 25  Tamil Nadu                 11 non-null     float64
 26  Telangana                  11 non-null     float64
 27  Tripura                    7 non-null      float64
 28  Uttar Pradesh              9 non-null      float64
 29  Uttarakhand                9 non-null      float64
 30  West Bengal1               0 non-null      float64
 31  Andaman & Nicobar Islands  7 non-null      float64
 32  Chandigarh                 9 non-null      float64
 33  Delhi                      11 non-null     float64
 34  Puducherry                 11 non-null     float64
 35  All_India GDP              11 non-null     float64
dtypes: float64(34), object(2)
memory usage: 3.2+ KB
In [7]:
gd.columns
Out[7]:
Index(['Items  Description', 'Duration', 'Andhra Pradesh ',
       'Arunachal Pradesh', 'Assam', 'Bihar', 'Chhattisgarh', 'Goa', 'Gujarat',
       'Haryana', 'Himachal Pradesh', 'Jammu & Kashmir', 'Jharkhand',
       'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur',
       'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Punjab', 'Rajasthan',
       'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh',
       'Uttarakhand', 'West Bengal1', 'Andaman & Nicobar Islands',
       'Chandigarh', 'Delhi', 'Puducherry', 'All_India GDP'],
      dtype='object')
Remove the rows: '(% Growth over the previous year)' and 'GSDP - CURRENT PRICES (` in Crore)' for the year 2016-17.¶
In [8]:
gd1 = gd[gd['Duration'] != '2016-17']
gd1
Out[8]:
Items Description Duration Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat Haryana ... Telangana Tripura Uttar Pradesh Uttarakhand West Bengal1 Andaman & Nicobar Islands Chandigarh Delhi Puducherry All_India GDP
0 GSDP - CURRENT PRICES (` in Crore) 2011-12 379402.00 11063.00 143175.00 247144.00 158074.00 42367.00 615606.00 297539.00 ... 359433.00 19208.00 724049.00 115523.00 NaN 3979.00 18768.00 343767.00 16818.00 8736039.00
1 GSDP - CURRENT PRICES (` in Crore) 2012-13 411404.00 12547.00 156864.00 282368.00 177511.00 38120.00 724495.00 347032.00 ... 401493.00 21663.00 822903.00 131835.00 NaN 4421.00 21609.00 391238.00 18875.00 9946636.00
2 GSDP - CURRENT PRICES (` in Crore) 2013-14 464272.00 14602.00 177745.00 317101.00 206690.00 35921.00 807623.00 400662.00 ... 452186.00 25593.00 944146.00 149817.00 NaN 5159.00 24787.00 443783.00 21870.00 11236635.00
3 GSDP - CURRENT PRICES (` in Crore) 2014-15 526468.00 16761.00 198098.00 373920.00 234982.00 40633.00 895027.00 437462.00 ... 511178.00 29667.00 1043371.00 161985.00 NaN 5721.00 27844.00 492424.00 24089.00 12433749.00
4 GSDP - CURRENT PRICES (` in Crore) 2015-16 609934.00 18784.00 224234.00 413503.00 260776.00 45002.00 994316.00 485184.00 ... 575631.00 NaN 1153795.00 184091.00 NaN NaN 30304.00 551963.00 26533.00 13675331.00
6 (% Growth over previous year) 2012-13 8.43 13.41 9.56 14.25 12.30 -10.02 17.69 16.63 ... 11.70 12.78 13.65 14.12 NaN 11.13 15.14 13.81 12.23 13.86
7 (% Growth over previous year) 2013-14 12.85 16.38 13.31 12.30 16.44 -5.77 11.47 15.45 ... 12.63 18.14 14.73 13.64 NaN 16.68 14.71 13.43 15.87 12.97
8 (% Growth over previous year) 2014-15 13.40 14.79 11.45 17.92 13.69 13.12 10.82 9.18 ... 13.05 15.92 10.51 8.12 NaN 10.89 12.33 10.96 10.14 10.65
9 (% Growth over previous year) 2015-16 15.85 12.07 13.19 10.59 10.98 10.75 11.09 10.91 ... 12.61 NaN 10.58 13.65 NaN NaN 8.84 12.09 10.15 9.99

9 rows × 36 columns

In [9]:
gd1.isnull().sum()
Out[9]:
Items  Description           0
Duration                     0
Andhra Pradesh               0
Arunachal Pradesh            0
Assam                        0
Bihar                        0
Chhattisgarh                 0
Goa                          0
Gujarat                      0
Haryana                      0
Himachal Pradesh             2
Jammu & Kashmir              0
Jharkhand                    0
Karnataka                    0
Kerala                       0
Madhya Pradesh               0
Maharashtra                  2
Manipur                      2
Meghalaya                    0
Mizoram                      2
Nagaland                     2
Odisha                       0
Punjab                       2
Rajasthan                    2
Sikkim                       0
Tamil Nadu                   0
Telangana                    0
Tripura                      2
Uttar Pradesh                0
Uttarakhand                  0
West Bengal1                 9
Andaman & Nicobar Islands    2
Chandigarh                   0
Delhi                        0
Puducherry                   0
All_India GDP                0
dtype: int64
In [10]:
gd1.isnull().all(axis=0)
Out[10]:
Items  Description           False
Duration                     False
Andhra Pradesh               False
Arunachal Pradesh            False
Assam                        False
Bihar                        False
Chhattisgarh                 False
Goa                          False
Gujarat                      False
Haryana                      False
Himachal Pradesh             False
Jammu & Kashmir              False
Jharkhand                    False
Karnataka                    False
Kerala                       False
Madhya Pradesh               False
Maharashtra                  False
Manipur                      False
Meghalaya                    False
Mizoram                      False
Nagaland                     False
Odisha                       False
Punjab                       False
Rajasthan                    False
Sikkim                       False
Tamil Nadu                   False
Telangana                    False
Tripura                      False
Uttar Pradesh                False
Uttarakhand                  False
West Bengal1                  True
Andaman & Nicobar Islands    False
Chandigarh                   False
Delhi                        False
Puducherry                   False
All_India GDP                False
dtype: bool
In [11]:
gd1.shape
Out[11]:
(9, 36)
In [12]:
gd1.iloc[6:].isnull().sum()
Out[12]:
Items  Description           0
Duration                     0
Andhra Pradesh               0
Arunachal Pradesh            0
Assam                        0
Bihar                        0
Chhattisgarh                 0
Goa                          0
Gujarat                      0
Haryana                      0
Himachal Pradesh             1
Jammu & Kashmir              0
Jharkhand                    0
Karnataka                    0
Kerala                       0
Madhya Pradesh               0
Maharashtra                  1
Manipur                      1
Meghalaya                    0
Mizoram                      1
Nagaland                     1
Odisha                       0
Punjab                       1
Rajasthan                    1
Sikkim                       0
Tamil Nadu                   0
Telangana                    0
Tripura                      1
Uttar Pradesh                0
Uttarakhand                  0
West Bengal1                 3
Andaman & Nicobar Islands    1
Chandigarh                   0
Delhi                        0
Puducherry                   0
All_India GDP                0
dtype: int64

Calculate the average growth of states for the duration 2013-14, 2014-15 and 2015-16 by taking the mean of the row '(% Growth over previous year)'. Compare the calculated values and plot them for the states.¶

In [13]:
avg_growth = gd1.iloc[6:]
avg_growth
Out[13]:
Items Description Duration Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat Haryana ... Telangana Tripura Uttar Pradesh Uttarakhand West Bengal1 Andaman & Nicobar Islands Chandigarh Delhi Puducherry All_India GDP
7 (% Growth over previous year) 2013-14 12.85 16.38 13.31 12.30 16.44 -5.77 11.47 15.45 ... 12.63 18.14 14.73 13.64 NaN 16.68 14.71 13.43 15.87 12.97
8 (% Growth over previous year) 2014-15 13.40 14.79 11.45 17.92 13.69 13.12 10.82 9.18 ... 13.05 15.92 10.51 8.12 NaN 10.89 12.33 10.96 10.14 10.65
9 (% Growth over previous year) 2015-16 15.85 12.07 13.19 10.59 10.98 10.75 11.09 10.91 ... 12.61 NaN 10.58 13.65 NaN NaN 8.84 12.09 10.15 9.99

3 rows × 36 columns

In [14]:
avg_growth.columns
Out[14]:
Index(['Items  Description', 'Duration', 'Andhra Pradesh ',
       'Arunachal Pradesh', 'Assam', 'Bihar', 'Chhattisgarh', 'Goa', 'Gujarat',
       'Haryana', 'Himachal Pradesh', 'Jammu & Kashmir', 'Jharkhand',
       'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur',
       'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Punjab', 'Rajasthan',
       'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh',
       'Uttarakhand', 'West Bengal1', 'Andaman & Nicobar Islands',
       'Chandigarh', 'Delhi', 'Puducherry', 'All_India GDP'],
      dtype='object')
In [15]:
average_growth_values = avg_growth[avg_growth.columns[2:34]].mean()
In [16]:
average_growth_values = average_growth_values.sort_values()
average_growth_rate = average_growth_values.to_frame(name='Average growth rate')
average_growth_rate
Out[16]:
Average growth rate
Goa 6.033333
Meghalaya 6.953333
Odisha 9.836667
Sikkim 10.486667
Jammu & Kashmir 10.900000
Gujarat 11.126667
Punjab 11.185000
Maharashtra 11.260000
Rajasthan 11.320000
Jharkhand 11.500000
Uttarakhand 11.803333
Haryana 11.846667
Uttar Pradesh 11.940000
Chandigarh 11.960000
Delhi 12.160000
Himachal Pradesh 12.280000
Tamil Nadu 12.336667
Kerala 12.583333
Madhya Pradesh 12.626667
Assam 12.650000
Telangana 12.763333
Bihar 13.603333
Chhattisgarh 13.703333
Andaman & Nicobar Islands 13.785000
Andhra Pradesh 14.033333
Karnataka 14.120000
Arunachal Pradesh 14.413333
Manipur 14.610000
Nagaland 16.415000
Tripura 17.030000
Mizoram 17.700000
West Bengal1 NaN
In [17]:
plt.figure(figsize=(12,10), dpi = 300)

sns.barplot(x = average_growth_rate['Average growth rate'], y = average_growth_values.index,palette='viridis')
plt.xlabel('Average Growth Rate', fontsize=12)
plt.ylabel('States', fontsize=12)
plt.title('Average Growth Rate for all the states',fontsize=13)
plt.show()
In [18]:
average_growth_rate['Average growth rate'][-5:]
Out[18]:
Manipur         14.610
Nagaland        16.415
Tripura         17.030
Mizoram         17.700
West Bengal1       NaN
Name: Average growth rate, dtype: float64

top 5 states as per average growth rate for the years 2013-14, 2014-15, 2015-16¶

In [19]:
avg_growth[['Mizoram','Tripura','Nagaland','Manipur','Arunachal Pradesh']]
Out[19]:
Mizoram Tripura Nagaland Manipur Arunachal Pradesh
7 23.1 18.14 21.98 17.83 16.38
8 12.3 15.92 10.85 11.39 14.79
9 NaN NaN NaN NaN 12.07
In [20]:
describe = pd.DataFrame(avg_growth.describe())
describe = describe.T
describe
Out[20]:
count mean std min 25% 50% 75% max
Andhra Pradesh 3.0 14.033333 1.597133 12.85 13.1250 13.400 14.6250 15.85
Arunachal Pradesh 3.0 14.413333 2.179549 12.07 13.4300 14.790 15.5850 16.38
Assam 3.0 12.650000 1.040961 11.45 12.3200 13.190 13.2500 13.31
Bihar 3.0 13.603333 3.834871 10.59 11.4450 12.300 15.1100 17.92
Chhattisgarh 3.0 13.703333 2.730024 10.98 12.3350 13.690 15.0650 16.44
Goa 3.0 6.033333 10.290444 -5.77 2.4900 10.750 11.9350 13.12
Gujarat 3.0 11.126667 0.326548 10.82 10.9550 11.090 11.2800 11.47
Haryana 3.0 11.846667 3.238245 9.18 10.0450 10.910 13.1800 15.45
Himachal Pradesh 2.0 12.280000 3.026417 10.14 11.2100 12.280 13.3500 14.42
Jammu & Kashmir 3.0 10.900000 6.642146 4.70 7.3950 10.090 14.0000 17.91
Jharkhand 3.0 11.500000 3.610374 7.92 9.6800 11.440 13.2900 15.14
Karnataka 3.0 14.120000 3.624969 11.42 12.0600 12.700 15.4700 18.24
Kerala 3.0 12.583333 0.654930 11.85 12.3200 12.790 12.9500 13.11
Madhya Pradesh 3.0 12.626667 2.408492 10.11 11.4850 12.860 13.8850 14.91
Maharashtra 2.0 11.260000 3.507250 8.78 10.0200 11.260 12.5000 13.74
Manipur 2.0 14.610000 4.553768 11.39 13.0000 14.610 16.2200 17.83
Meghalaya 3.0 6.953333 2.401548 4.87 5.6400 6.410 7.9950 9.58
Mizoram 2.0 17.700000 7.636753 12.30 15.0000 17.700 20.4000 23.10
Nagaland 2.0 16.415000 7.870098 10.85 13.6325 16.415 19.1975 21.98
Odisha 3.0 9.836667 3.411412 6.19 8.2800 10.370 11.6600 12.95
Punjab 2.0 11.185000 1.746554 9.95 10.5675 11.185 11.8025 12.42
Rajasthan 2.0 11.320000 0.070711 11.27 11.2950 11.320 11.3450 11.37
Sikkim 3.0 10.486667 1.622108 9.39 9.5550 9.720 11.0350 12.35
Tamil Nadu 3.0 12.336667 1.268910 10.99 11.7500 12.510 13.0100 13.51
Telangana 3.0 12.763333 0.248462 12.61 12.6200 12.630 12.8400 13.05
Tripura 2.0 17.030000 1.569777 15.92 16.4750 17.030 17.5850 18.14
Uttar Pradesh 3.0 11.940000 2.416464 10.51 10.5450 10.580 12.6550 14.73
Uttarakhand 3.0 11.803333 3.189864 8.12 10.8800 13.640 13.6450 13.65
West Bengal1 0.0 NaN NaN NaN NaN NaN NaN NaN
Andaman & Nicobar Islands 2.0 13.785000 4.094148 10.89 12.3375 13.785 15.2325 16.68
Chandigarh 3.0 11.960000 2.952440 8.84 10.5850 12.330 13.5200 14.71
Delhi 3.0 12.160000 1.236487 10.96 11.5250 12.090 12.7600 13.43
Puducherry 3.0 12.053333 3.305334 10.14 10.1450 10.150 13.0100 15.87
All_India GDP 3.0 11.203333 1.565162 9.99 10.3200 10.650 11.8100 12.97
In [22]:
describe[(describe['mean']>12) & (describe['std']<2)]
Out[22]:
count mean std min 25% 50% 75% max
Andhra Pradesh 3.0 14.033333 1.597133 12.85 13.125 13.40 14.625 15.85
Assam 3.0 12.650000 1.040961 11.45 12.320 13.19 13.250 13.31
Kerala 3.0 12.583333 0.654930 11.85 12.320 12.79 12.950 13.11
Tamil Nadu 3.0 12.336667 1.268910 10.99 11.750 12.51 13.010 13.51
Telangana 3.0 12.763333 0.248462 12.61 12.620 12.63 12.840 13.05
Tripura 2.0 17.030000 1.569777 15.92 16.475 17.03 17.585 18.14
Delhi 3.0 12.160000 1.236487 10.96 11.525 12.09 12.760 13.43
In [23]:
describe[(describe['mean']<12) & (describe['std']>2)]
Out[23]:
count mean std min 25% 50% 75% max
Goa 3.0 6.033333 10.290444 -5.77 2.490 10.75 11.935 13.12
Haryana 3.0 11.846667 3.238245 9.18 10.045 10.91 13.180 15.45
Jammu & Kashmir 3.0 10.900000 6.642146 4.70 7.395 10.09 14.000 17.91
Jharkhand 3.0 11.500000 3.610374 7.92 9.680 11.44 13.290 15.14
Maharashtra 2.0 11.260000 3.507250 8.78 10.020 11.26 12.500 13.74
Meghalaya 3.0 6.953333 2.401548 4.87 5.640 6.41 7.995 9.58
Odisha 3.0 9.836667 3.411412 6.19 8.280 10.37 11.660 12.95
Uttar Pradesh 3.0 11.940000 2.416464 10.51 10.545 10.58 12.655 14.73
Uttarakhand 3.0 11.803333 3.189864 8.12 10.880 13.64 13.645 13.65
Chandigarh 3.0 11.960000 2.952440 8.84 10.585 12.33 13.520 14.71
In [32]:
gd1 = gd[gd['Duration'] != '2015-16']
gd1.head()
Out[32]:
Items Description Duration Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat Haryana ... Telangana Tripura Uttar Pradesh Uttarakhand West Bengal1 Andaman & Nicobar Islands Chandigarh Delhi Puducherry All_India GDP
0 GSDP - CURRENT PRICES (` in Crore) 2011-12 379402.0 11063.0 143175.0 247144.0 158074.0 42367.0 615606.0 297539.0 ... 359433.0 19208.0 724049.0 115523.0 NaN 3979.0 18768.0 343767.0 16818.0 8736039.0
1 GSDP - CURRENT PRICES (` in Crore) 2012-13 411404.0 12547.0 156864.0 282368.0 177511.0 38120.0 724495.0 347032.0 ... 401493.0 21663.0 822903.0 131835.0 NaN 4421.0 21609.0 391238.0 18875.0 9946636.0
2 GSDP - CURRENT PRICES (` in Crore) 2013-14 464272.0 14602.0 177745.0 317101.0 206690.0 35921.0 807623.0 400662.0 ... 452186.0 25593.0 944146.0 149817.0 NaN 5159.0 24787.0 443783.0 21870.0 11236635.0
3 GSDP - CURRENT PRICES (` in Crore) 2014-15 526468.0 16761.0 198098.0 373920.0 234982.0 40633.0 895027.0 437462.0 ... 511178.0 29667.0 1043371.0 161985.0 NaN 5721.0 27844.0 492424.0 24089.0 12433749.0
5 GSDP - CURRENT PRICES (` in Crore) 2016-17 699307.0 NaN NaN NaN 290140.0 NaN NaN 547396.0 ... 654294.0 NaN NaN NaN NaN NaN NaN 622385.0 29557.0 15251028.0

5 rows × 36 columns

In [33]:
total_GDP_15_16 = gd1[(gd1['Items  Description'] == 'GSDP - CURRENT PRICES (` in Crore)')]
total_GDP_15_16
Out[33]:
Items Description Duration Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Goa Gujarat Haryana ... Telangana Tripura Uttar Pradesh Uttarakhand West Bengal1 Andaman & Nicobar Islands Chandigarh Delhi Puducherry All_India GDP
0 GSDP - CURRENT PRICES (` in Crore) 2011-12 379402.0 11063.0 143175.0 247144.0 158074.0 42367.0 615606.0 297539.0 ... 359433.0 19208.0 724049.0 115523.0 NaN 3979.0 18768.0 343767.0 16818.0 8736039.0
1 GSDP - CURRENT PRICES (` in Crore) 2012-13 411404.0 12547.0 156864.0 282368.0 177511.0 38120.0 724495.0 347032.0 ... 401493.0 21663.0 822903.0 131835.0 NaN 4421.0 21609.0 391238.0 18875.0 9946636.0
2 GSDP - CURRENT PRICES (` in Crore) 2013-14 464272.0 14602.0 177745.0 317101.0 206690.0 35921.0 807623.0 400662.0 ... 452186.0 25593.0 944146.0 149817.0 NaN 5159.0 24787.0 443783.0 21870.0 11236635.0
3 GSDP - CURRENT PRICES (` in Crore) 2014-15 526468.0 16761.0 198098.0 373920.0 234982.0 40633.0 895027.0 437462.0 ... 511178.0 29667.0 1043371.0 161985.0 NaN 5721.0 27844.0 492424.0 24089.0 12433749.0
5 GSDP - CURRENT PRICES (` in Crore) 2016-17 699307.0 NaN NaN NaN 290140.0 NaN NaN 547396.0 ... 654294.0 NaN NaN NaN NaN NaN NaN 622385.0 29557.0 15251028.0

5 rows × 36 columns

In [42]:
total_GDP_15_16_states = total_GDP_15_16[total_GDP_15_16.columns[2:34]].transpose()
total_GDP_15_16_states = total_GDP_15_16_states.rename(columns={4: 'Total GDP of States 2015-16'})
total_GDP_15_16_states = total_GDP_15_16_states.dropna()
total_GDP_15_16_states
Out[42]:
0 1 2 3 5
Andhra Pradesh 379402.0 411404.0 464272.0 526468.0 699307.0
Chhattisgarh 158074.0 177511.0 206690.0 234982.0 290140.0
Haryana 297539.0 347032.0 400662.0 437462.0 547396.0
Madhya Pradesh 315561.0 380924.0 437737.0 481982.0 640484.0
Meghalaya 19918.0 21872.0 22938.0 24408.0 29567.0
Odisha 227872.0 258275.0 291709.0 321971.0 378991.0
Tamil Nadu 751485.0 855481.0 971090.0 1092564.0 1338766.0
Telangana 359433.0 401493.0 452186.0 511178.0 654294.0
Delhi 343767.0 391238.0 443783.0 492424.0 622385.0
In [49]:
top_5_eco = total_GDP_15_16_states[-5:]
top_5_eco
Out[49]:
0 1 2 3 5
Meghalaya 19918.0 21872.0 22938.0 24408.0 29567.0
Odisha 227872.0 258275.0 291709.0 321971.0 378991.0
Tamil Nadu 751485.0 855481.0 971090.0 1092564.0 1338766.0
Telangana 359433.0 401493.0 452186.0 511178.0 654294.0
Delhi 343767.0 391238.0 443783.0 492424.0 622385.0
In [50]:
bottom_5_eco = total_GDP_15_16_states[:5]
bottom_5_eco
Out[50]:
0 1 2 3 5
Andhra Pradesh 379402.0 411404.0 464272.0 526468.0 699307.0
Chhattisgarh 158074.0 177511.0 206690.0 234982.0 290140.0
Haryana 297539.0 347032.0 400662.0 437462.0 547396.0
Madhya Pradesh 315561.0 380924.0 437737.0 481982.0 640484.0
Meghalaya 19918.0 21872.0 22938.0 24408.0 29567.0

part b¶

In [84]:
Andhra_Pradesh = pd.read_csv('NAD-Andhra_Pradesh-GSVA_cur_2016-17.csv')
In [85]:
Arunachal_Pradesh = pd.read_csv('NAD-Arunachal_Pradesh-GSVA_cur_2015-16.csv')
In [86]:
Assam = pd.read_csv('NAD-Assam-GSVA_cur_2015-16.csv')
In [87]:
Bihar = pd.read_csv('NAD-Bihar-GSVA_cur_2015-16.csv')
In [88]:
Chhattisgarh = pd.read_csv('NAD-Chhattisgarh-GSVA_cur_2016-17.csv')
In [89]:
Goa = pd.read_csv('NAD-Goa-GSVA_cur_2015-16.csv')
In [90]:
Gujarat = pd.read_csv('NAD-Gujarat-GSVA_cur_2015-16.csv')
In [91]:
Haryana = pd.read_csv('NAD-Haryana-GSVA_cur_2016-17.csv')
In [92]:
Himachal_Pradesh = pd.read_csv('NAD-Himachal_Pradesh-GSVA_cur_2014-15.csv')
In [93]:
Jharkhand = pd.read_csv('NAD-Jharkhand-GSVA_cur_2015-16.csv')
In [94]:
Karnataka = pd.read_csv('NAD-Karnataka-GSVA_cur_2015-16.csv')
In [95]:
Kerala = pd.read_csv('NAD-Kerala-GSVA_cur_2015-16.csv')
In [115]:
Madhya_Pradesh = pd.read_csv('NAD-Madhya_Pradesh-GSVA_cur_2016-17.csv')
In [116]:
Maharashtra = pd.read_csv('NAD-Maharashtra-GSVA_cur_2014-15.csv')
In [117]:
Meghalaya = pd.read_csv('NAD-Meghalaya-GSVA_cur_2016-17.csv')
In [118]:
Mizoram = pd.read_csv('NAD-Mizoram-GSVA_cur_2014-15.csv')
In [119]:
Nagaland = pd.read_csv('NAD-Nagaland-GSVA_cur_2014-15.csv')
In [120]:
Odisha = pd.read_csv('NAD-Odisha-GSVA_cur_2016-17.csv')
In [121]:
Punjab = pd.read_csv('NAD-Punjab-GSVA_cur_2014-15.csv')
In [122]:
Rajasthan = pd.read_csv('NAD-Rajasthan-GSVA_cur_2014-15.csv')
In [123]:
Sikkim = pd.read_csv('NAD-Sikkim-GSVA_cur_2015-16.csv')
In [124]:
Tamil_Nadu = pd.read_csv('NAD-Tamil_Nadu-GSVA_cur_2016-17.csv')
In [125]:
Telangana = pd.read_csv('NAD-Telangana-GSVA_cur_2016-17.csv')
In [126]:
Tripura = pd.read_csv('NAD-Tripura-GSVA_cur_2014-15.csv')
In [127]:
Uttar_Pradesh = pd.read_csv('NAD-Uttar_Pradesh-GSVA_cur_2015-16.csv')
In [128]:
Uttarakhand = pd.read_csv('NAD-Uttarakhand-GSVA_cur_2015-16.csv')
In [130]:
andhra_pradesh = Andhra_Pradesh[['S.No.','Item', '2014-15']]
andhra_pradesh = andhra_pradesh.rename(columns={'2014-15': 'Andhra_Pradesh'})

arunachal_pradesh = Arunachal_Pradesh[['S.No.','Item', '2014-15']]
arunachal_pradesh = arunachal_pradesh.rename(columns={'2014-15': 'Arunachal_Pradesh'})

assam = Assam[['S.No.','Item', '2014-15']]
assam = assam.rename(columns={'2014-15': 'Assam'})

bihar = Bihar[['S.No.','Item', '2014-15']]
bihar = bihar.rename(columns={'2014-15': 'Bihar'})

chhattisgarh = Chhattisgarh[['S.No.','Item', '2014-15']]
chhattisgarh = chhattisgarh.rename(columns={'2014-15': 'Chhattisgarh'})

goa = Goa[['S.No.','Item', '2014-15']]
goa = goa.rename(columns={'2014-15': 'Goa'})

gujarat = Gujarat[['S.No.','Item', '2014-15']]
gujarat = gujarat.rename(columns={'2014-15': 'Gujarat'})

haryana = Haryana[['S.No.','Item', '2014-15']]
haryana = haryana.rename(columns={'2014-15': 'Haryana'})

himachal_Pradesh = Himachal_Pradesh[['S.No.','Item', '2014-15']]
himachal_Pradesh = himachal_Pradesh.rename(columns={'2014-15': 'Himachal_Pradesh'})

jharkhand = Jharkhand[['S.No.','Item', '2014-15']]
jharkhand = jharkhand.rename(columns={'2014-15': 'Jharkhand'})

karnataka = Karnataka[['S.No.','Item', '2014-15']]
karnataka = karnataka.rename(columns={'2014-15': 'Karnataka'})

kerala = Kerala[['S.No.','Item', '2014-15']]
kerala = kerala.rename(columns={'2014-15': 'Kerala'})

madhya_pradesh = Madhya_Pradesh[['S.No.','Item', '2014-15']]
madhya_pradesh = madhya_pradesh.rename(columns={'2014-15': 'Madhya_Pradesh'})

maharashtra = Maharashtra[['S.No.','Item', '2014-15']]
maharashtra = maharashtra.rename(columns={'2014-15': 'Maharashtra'})


meghalaya = Meghalaya[['S.No.','Item', '2014-15']]
meghalaya = meghalaya.rename(columns={'2014-15': 'Meghalaya'})

mizoram = Mizoram[['S.No.','Item', '2014-15']]
mizoram = mizoram.rename(columns={'2014-15': 'Mizoram'})

nagaland = Nagaland[['S.No.','Item', '2014-15']]
nagaland = nagaland.rename(columns={'2014-15': 'Nagaland'})

odisha = Odisha[['S.No.','Item', '2014-15']]
odisha = odisha.rename(columns={'2014-15': 'Odisha'})

punjab = Punjab[['S.No.','Item', '2014-15']]
punjab = punjab.rename(columns={'2014-15': 'Punjab'})

rajasthan = Rajasthan[['S.No.','Item', '2014-15']]
rajasthan = rajasthan.rename(columns={'2014-15': 'Rajasthan'})

sikkim = Sikkim[['S.No.','Item', '2014-15']]
sikkim = sikkim.rename(columns={'2014-15': 'Sikkim'})

tamil_nadu = Tamil_Nadu[['S.No.','Item', '2014-15']]
tamil_nadu = tamil_nadu.rename(columns={'2014-15': 'Tamil_Nadu'})

telangana = Telangana[['S.No.','Item', '2014-15']]
telangana = telangana.rename(columns={'2014-15': 'Telangana'})

tripura = Tripura[['S.No.','Item', '2014-15']]
tripura = tripura.rename(columns={'2014-15': 'Tripura'})

uttar_pradesh = Uttar_Pradesh[['S.No.','Item', '2014-15']]
uttar_pradesh = uttar_pradesh.rename(columns={'2014-15': 'Uttar_Pradesh'})

uttarakhand = Uttarakhand[['S.No.','Item', '2014-15']]
uttarakhand = uttarakhand.rename(columns={'2014-15': 'Uttarakhand'})
In [132]:
dfs = [andhra_pradesh,arunachal_pradesh, assam, bihar, chhattisgarh, goa, gujarat, haryana,himachal_Pradesh,
       jharkhand, karnataka,kerala,madhya_pradesh, maharashtra,meghalaya,mizoram, nagaland,odisha,
       punjab,rajasthan,sikkim,tamil_nadu,telangana,tripura,uttarakhand, uttar_pradesh]


from functools import reduce
df_final = reduce(lambda left,right: pd.merge(left,right,how ='left',on=['S.No.', 'Item']), dfs)
In [133]:
df_final.columns
Out[133]:
Index(['S.No.', 'Item', 'Andhra_Pradesh', 'Arunachal_Pradesh', 'Assam',
       'Bihar', 'Chhattisgarh', 'Goa', 'Gujarat', 'Haryana',
       'Himachal_Pradesh', 'Jharkhand', 'Karnataka', 'Kerala',
       'Madhya_Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland',
       'Odisha', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil_Nadu', 'Telangana',
       'Tripura', 'Uttarakhand', 'Uttar_Pradesh'],
      dtype='object')
In [134]:
df_final = df_final.rename(columns={'Andhra_Pradesh':'Andhra Pradesh', 'Arunachal_Pradesh':'Arunachal Pradesh',
                                   'Himachal_Pradesh':'Himachal Pradesh','Madhya_Pradesh':'Madhya Pradesh',
                                   'Tamil_Nadu':'Tamil Nadu','Uttar_Pradesh':'Uttar Pradesh',
                                   'Chhattisgarh':'Chhatisgarh','Uttarakhand':'Uttrakhand'})
In [135]:
df_final
Out[135]:
S.No. Item Andhra Pradesh Arunachal Pradesh Assam Bihar Chhatisgarh Goa Gujarat Haryana ... Nagaland Odisha Punjab Rajasthan Sikkim Tamil Nadu Telangana Tripura Uttrakhand Uttar Pradesh
0 1 Agriculture, forestry and fishing 14819416 686117 3855548 7951890 3948847 308507 13769969.00 8015238.0 ... 607897 6422978 9285716 15044394 137447 13064238.0 7591501 799825.0 1601423.0 25097754
1 1.1 Crops 7893514 415520 2890544 4688237 2613371 140421 9671086.00 4636731.0 ... 375825 4382636 5690972 7673441 114976 7297820.0 4162493 397591.0 866146.0 16215212
2 1.2 Livestock 4309078 38387 173478 2060296 352208 30141 2698910.00 2916173.0 ... 123800 788243 2638842 5356257 17338 4693361.0 2951299 88176.0 391188.0 7096876
3 1.3 Forestry and logging 346160 224017 261987 550132 597785 15744 761616.00 352254.0 ... 99802 791463 848245 1956660 4529 392705.0 210741 145096.0 339293.0 1404936
4 1.4 Fishing and aquaculture 2270664 8193 529539 653224 385483 122201 638357.00 110080.0 ... 8470 460636 107657 58036 604 680352.0 266968 168961.0 4796.0 380730
5 2 Mining and quarrying 1484300 30842 1471149 68107 2451970 3622 2117218.00 25186.0 ... 8280 2586328 10354 4069385 1329 265536.0 1541853 142391.0 244549.0 901501
6 Total Primary 16303716 716959 5326697 8019997 6400817 312129 15887187.00 8040424.0 ... 616178 9009306 9296070 19113780 138776 13329774.0 9133354 942216.0 1845972.0 25999255
7 3 Manufacturing 4672266 26120 2002936 2189965 4370593 1177608 24087538.00 7756921.0 ... 18346 5754229 4790341 6552580 550697 18914794.0 6353711 228625.0 5866252.0 12261649
8 4 Electricity, gas, water supply & other utility... 1151729 113527 296587 345168 1198438 204110 3409983.00 1101919.0 ... 37944 833067 911611 1122888 212499 1710379.0 716266 77870.0 433880.0 2030625
9 5 Construction 4664889 147842 1733568 3449763 2669855 165819 5526017.00 3702571.0 ... 156072 2402396 2202962 5353326 82058 12216718.0 2854024 177899.0 1342733.0 11256450
10 Total Secondary 10488884 287489 4033091 5984896 8238886 1547536 33023538.00 12561411.0 ... 212361 8989693 7904914 13028794 845253 32841892.0 9924001 484393.0 7642865.0 25548724
11 6 Trade, repair, hotels and restaurants 4233400 60421 2987155 7448373 1535571 380927 10178713.00 4986319.0 ... 140781 3149555 4419919 7297290 70568 12895842.0 6494607 390423.0 1743106.0 9437243
12 6.1 Trade & repair services 3716000 56796 2876251 7081391 1414164 343492 10178713.00 4817784.0 ... 134174 2886789 4201252 6942748 64624 11252588.0 5724128 390423.0 1534073.0 8476139
13 6.2 Hotels & restaurants 517400 3625 110904 366982 121407 37434 NaN 168535.0 ... 6607 262766 218667 354543 5945 1643253.0 770479 NaN 209033.0 961104
14 7 Transport, storage, communication & services r... 5076984 35203 1194568 3147173 871770 189656 4555910.00 2560623.0 ... 77521 2034016 1951809 3814461 47347 7188320.0 3604741 155956.0 1066693.0 7404509
15 7.1 Railways 424228 59 252509 462413 159176 15649 511593.00 423873.0 ... 336 341494 233389 464638 0 468553.0 199686 305.0 21295.0 1618742
16 7.2 Road transport 2816000 15467 507668 1572288 386628 46171 NaN 1452364.0 ... 34548 973144 928575 2121206 35283 3660994.0 2055658 NaN NaN 3645747
17 7.3 Water transport 94200 0 4502 2228 0 17820 NaN NaN ... 600 50349 0 0 0 70414.0 0 NaN NaN 681
18 7.4 Air transport 14900 0 26223 13599 9507 46359 NaN NaN ... 4153 15354 4473 13469 0 180836.0 120691 NaN 3889.0 36582
19 7.5 Services incidental to transport 780200 109 35739 166600 5232 19272 NaN 190269.0 ... 0 117469 48124 47609 0 NaN 454909 NaN -76.0 16323
20 7.6 Storage 18700 0 10308 10618 16675 357 57634.00 14459.0 ... 89 22675 76429 16584 0 39834.0 19805 254.0 660.0 171696
21 7.7 Communication & services related to broadcasting 928756 19568 357619 919427 294552 44028 1242520.00 479658.0 ... 37794 513531 660819 1150955 12064 1903283.0 753992 66676.0 733778.0 1914737
22 8 Financial services 1900863 25207 543651 1178022 739057 233618 4606644.00 1671486.0 ... 60393 1065147 2057520 1827413 21079 5598498.0 3023729 86094.0 385030.0 3392275
23 9 Real estate, ownership of dwelling & professio... 4405409 48418 1412466 3740641 2462166 407099 5179502.00 6970183.0 ... 159651 2348714 3142786 6451997 75330 16830213.0 9478839 190704.0 831307.0 14548185
24 10 Public administration 2200897 243867 1373611 2078171 867982 346486 2576195.00 1036377.0 ... 295424 1318221 1842730 2460364 119514 3400800.0 1711265 338244.0 579409.0 6152124
25 11 Other services 4215389 218728 1795658 4587589 1112232 180431 3123413.00 2001581.0 ... 259186 2340603 3303041 4164287 149265 7430115.0 4158229 323287.0 982430.0 5034623
26 Total Tertiary 22032942 631844 9307109 22179969 7588778 1738217 30220377.00 19226568.0 ... 992956 12256258 16717805 26015812 483103 53343788.0 28471410 1484709.0 5587975.0 45968959
27 12 TOTAL GSVA at basic prices 48825542 1636292 18666897 36184863 22228481 3597882 79131102.00 39828404.0 ... 1821495 30255256 33918789 58158386 1467133 99515453.0 47528765 2911319.0 15076812.0 97516938
28 13 Taxes on Products 5512100 70099 1725309 3213546 2601791 527279 12353171.04 4985670.0 ... 57674 3151184 3794100 5394503 72200 12507325.0 4425700 149345.0 1434856.0 10107396
29 14 Subsidies on products 1690800 30272 582406 2006421 1332092 61854 1981546.00 1067867.0 ... 37745 1209349 911800 2333442 18400 2766405.0 836700 94002.0 313139.0 3287219
30 15 Gross State Domestic Product 52646842 1676119 19809800 37391988 23498180 4063307 89502727.00 43746207.0 ... 1841424 32197092 36801089 61219447 1520933 109256373.0 51117765 2966662.0 16198529.0 104337115
31 16 Population ('00) 501510 14870 326780 1101240 270530 14950 633590.00 266620.0 ... 20550 435220 290673 721610 6330 745760.0 367660 38350.0 105820.0 2109940
32 17 Per Capita GSDP (Rs.) 104977 112718 60621 33954 86860 271793 141263.00 164077.0 ... 89607 73979 126606 84837 240274 146503.0 139035 77358.0 153076.0 49450

33 rows × 28 columns

Creating the GDP per capita Data Frame¶

In [136]:
gdp_per_capita = df_final.iloc[32][2:].sort_values()
gdp_per_capita = gdp_per_capita.to_frame(name = 'GDP per capita')
gdp_per_capita
Out[136]:
GDP per capita
Bihar 33954
Uttar Pradesh 49450
Assam 60621
Jharkhand 62091
Madhya Pradesh 62989
Odisha 73979
Meghalaya 76228.0
Tripura 77358.0
Rajasthan 84837
Chhatisgarh 86860
Nagaland 89607
Mizoram 97687
Andhra Pradesh 104977
Arunachal Pradesh 112718
Punjab 126606
Telangana 139035
Gujarat 141263.0
Karnataka 145141
Tamil Nadu 146503.0
Himachal Pradesh 147330
Maharashtra 152853
Uttrakhand 153076.0
Kerala 154778.0
Haryana 164077.0
Sikkim 240274
Goa 271793
In [141]:
plt.figure(figsize=(12,8), dpi=600)                             

sns.barplot(x = gdp_per_capita['GDP per capita'], y =gdp_per_capita.index, palette='Reds' )
plt.xlabel('GDP per capita', fontsize=12)
plt.ylabel('States', fontsize=12)
plt.title('GDP per capita vs States',fontsize=12)
plt.show()
In [142]:
top_5_gdp_per_capita = gdp_per_capita[-5:]
top_5_gdp_per_capita
Out[142]:
GDP per capita
Uttrakhand 153076.0
Kerala 154778.0
Haryana 164077.0
Sikkim 240274
Goa 271793
In [143]:
bottom_5_gdp_per_capita = gdp_per_capita[:5]
bottom_5_gdp_per_capita
Out[143]:
GDP per capita
Bihar 33954
Uttar Pradesh 49450
Assam 60621
Jharkhand 62091
Madhya Pradesh 62989
In [144]:
ratio = gdp_per_capita['GDP per capita'].max()/gdp_per_capita['GDP per capita'].min()
print('The Ratio of highest per capita GDP to the lowest per capita GDP is: ',ratio)
The Ratio of highest per capita GDP to the lowest per capita GDP is:  8.004741709371503
In [145]:
primary = df_final[df_final['Item']=='Primary']
secondary = df_final[df_final['Item']=='Secondary']
tertiary = df_final[df_final['Item']=='Tertiary']
gdp = df_final[df_final['Item']=='Gross State Domestic Product']

pst = pd.concat([primary, secondary,tertiary,gdp], axis = 0).reset_index()
pst =  pst.drop(['index','S.No.'], axis = 1).set_index('Item')
In [146]:
pst
Out[146]:
Andhra Pradesh Arunachal Pradesh Assam Bihar Chhatisgarh Goa Gujarat Haryana Himachal Pradesh Jharkhand ... Nagaland Odisha Punjab Rajasthan Sikkim Tamil Nadu Telangana Tripura Uttrakhand Uttar Pradesh
Item
Primary 16303716 716959 5326697 8019997 6400817 312129 15887187.0 8040424.0 1548366 5248354 ... 616178 9009306 9296070 19113780 138776 13329774.0 9133354 942216.0 1845972.0 25999255
Secondary 10488884 287489 4033091 5984896 8238886 1547536 33023538.0 12561411.0 4119162 6241471 ... 212361 8989693 7904914 13028794 845253 32841892.0 9924001 484393.0 7642865.0 25548724
Tertiary 22032942 631844 9307109 22179969 7588778 1738217 30220377.0 19226568.0 4133326 8133341 ... 992956 12256258 16717805 26015812 483103 53343788.0 28471410 1484709.0 5587975.0 45968959
Gross State Domestic Product 52646842 1676119 19809800 37391988 23498180 4063307 89502727.0 43746207.0 10436879 21710718 ... 1841424 32197092 36801089 61219447 1520933 109256373.0 51117765 2966662.0 16198529.0 104337115

4 rows × 26 columns

In [147]:
pst.loc['primary_percentage'] = pst.loc['Primary'] / pst.loc['Gross State Domestic Product'] * 100
pst.loc['secondary_percentage'] = pst.loc['Secondary'] / pst.loc['Gross State Domestic Product'] * 100
pst.loc['tertiary_percentage'] = pst.loc['Tertiary'] / pst.loc['Gross State Domestic Product'] * 100
In [148]:
pst
Out[148]:
Andhra Pradesh Arunachal Pradesh Assam Bihar Chhatisgarh Goa Gujarat Haryana Himachal Pradesh Jharkhand ... Nagaland Odisha Punjab Rajasthan Sikkim Tamil Nadu Telangana Tripura Uttrakhand Uttar Pradesh
Item
Primary 1.630372e+07 7.169590e+05 5.326697e+06 8.019997e+06 6.400817e+06 3.121290e+05 1.588719e+07 8.040424e+06 1.548366e+06 5.248354e+06 ... 6.161780e+05 9.009306e+06 9.296070e+06 1.911378e+07 1.387760e+05 1.332977e+07 9.133354e+06 9.422160e+05 1.845972e+06 2.599926e+07
Secondary 1.048888e+07 2.874890e+05 4.033091e+06 5.984896e+06 8.238886e+06 1.547536e+06 3.302354e+07 1.256141e+07 4.119162e+06 6.241471e+06 ... 2.123610e+05 8.989693e+06 7.904914e+06 1.302879e+07 8.452530e+05 3.284189e+07 9.924001e+06 4.843930e+05 7.642865e+06 2.554872e+07
Tertiary 2.203294e+07 6.318440e+05 9.307109e+06 2.217997e+07 7.588778e+06 1.738217e+06 3.022038e+07 1.922657e+07 4.133326e+06 8.133341e+06 ... 9.929560e+05 1.225626e+07 1.671780e+07 2.601581e+07 4.831030e+05 5.334379e+07 2.847141e+07 1.484709e+06 5.587975e+06 4.596896e+07
Gross State Domestic Product 5.264684e+07 1.676119e+06 1.980980e+07 3.739199e+07 2.349818e+07 4.063307e+06 8.950273e+07 4.374621e+07 1.043688e+07 2.171072e+07 ... 1.841424e+06 3.219709e+07 3.680109e+07 6.121945e+07 1.520933e+06 1.092564e+08 5.111776e+07 2.966662e+06 1.619853e+07 1.043371e+08
primary_percentage 3.096808e+01 4.277495e+01 2.688920e+01 2.144844e+01 2.723963e+01 7.681649e+00 1.775051e+01 1.837971e+01 1.483553e+01 2.417402e+01 ... 3.346204e+01 2.798174e+01 2.526031e+01 3.122175e+01 9.124399e+00 1.220045e+01 1.786728e+01 3.176014e+01 1.139592e+01 2.491851e+01
secondary_percentage 1.992310e+01 1.715206e+01 2.035907e+01 1.600582e+01 3.506180e+01 3.808563e+01 3.689668e+01 2.871429e+01 3.946737e+01 2.874834e+01 ... 1.153243e+01 2.792082e+01 2.148011e+01 2.128212e+01 5.557464e+01 3.005947e+01 1.941400e+01 1.632788e+01 4.718246e+01 2.448671e+01
tertiary_percentage 4.185045e+01 3.769685e+01 4.698235e+01 5.931744e+01 3.229517e+01 4.277838e+01 3.376476e+01 4.395025e+01 3.960308e+01 3.746233e+01 ... 5.392327e+01 3.806635e+01 4.542747e+01 4.249599e+01 3.176360e+01 4.882442e+01 5.569768e+01 5.004645e+01 3.449681e+01 4.405811e+01

7 rows × 26 columns

In [149]:
pst = pst.T
pst = pst.sort_values('Gross State Domestic Product')
pst
Out[149]:
Item Primary Secondary Tertiary Gross State Domestic Product primary_percentage secondary_percentage tertiary_percentage
Mizoram 225598.0 270072.0 637619.0 1155933.0 19.516529 23.363984 55.160550
Sikkim 138776.0 845253.0 483103.0 1520933.0 9.124399 55.574637 31.763595
Arunachal Pradesh 716959.0 287489.0 631844.0 1676119.0 42.774946 17.152064 37.696846
Nagaland 616178.0 212361.0 992956.0 1841424.0 33.462038 11.532434 53.923268
Meghalaya 451050.0 637942.0 1200655.0 2440807.0 18.479544 26.136520 49.190903
Tripura 942216.0 484393.0 1484709.0 2966662.0 31.760140 16.327880 50.046450
Goa 312129.0 1547536.0 1738217.0 4063307.0 7.681649 38.085628 42.778382
Himachal Pradesh 1548366.0 4119162.0 4133326.0 10436879.0 14.835527 39.467373 39.603084
Uttrakhand 1845972.0 7642865.0 5587975.0 16198529.0 11.395924 47.182463 34.496805
Assam 5326697.0 4033091.0 9307109.0 19809800.0 26.889201 20.359070 46.982347
Jharkhand 5248354.0 6241471.0 8133341.0 21710718.0 24.174023 28.748340 37.462331
Chhatisgarh 6400817.0 8238886.0 7588778.0 23498180.0 27.239629 35.061805 32.295173
Odisha 9009306.0 8989693.0 12256258.0 32197092.0 27.981738 27.920823 38.066351
Punjab 9296070.0 7904914.0 16717805.0 36801089.0 25.260312 21.480109 45.427474
Bihar 8019997.0 5984896.0 22179969.0 37391988.0 21.448437 16.005825 59.317437
Haryana 8040424.0 12561411.0 19226568.0 43746207.0 18.379705 28.714286 43.950252
Madhya Pradesh 17854020.0 10044889.0 18117360.0 48198169.0 37.042942 20.840810 37.589312
Telangana 9133354.0 9924001.0 28471410.0 51117765.0 17.867280 19.413996 55.697682
Kerala 6489442.0 12070040.0 29673778.0 52600230.0 12.337288 22.946744 56.413780
Andhra Pradesh 16303716.0 10488884.0 22032942.0 52646842.0 30.968080 19.923102 41.850453
Rajasthan 19113780.0 13028794.0 26015812.0 61219447.0 31.221746 21.282116 42.495993
Gujarat 15887187.0 33023538.0 30220377.0 89502727.0 17.750506 36.896684 33.764756
Karnataka 12066304.0 20484404.0 50490630.0 92178806.0 13.090107 22.222466 54.774663
Uttar Pradesh 25999255.0 25548724.0 45968959.0 104337115.0 24.918511 24.486707 44.058108
Tamil Nadu 13329774.0 32841892.0 53343788.0 109256373.0 12.200454 30.059475 48.824418
Maharashtra 21758383.0 47445207.0 88631076.0 179212165.0 12.141131 26.474323 49.455948
In [152]:
plt.figure(figsize=(12,10), dpi =600)

bars1 = pst['primary_percentage']
bars2 = pst['secondary_percentage']
bars3 = pst['tertiary_percentage']
 
legends = ['Primary %', 'Secondary %', 'Tertiary %'] 
bars = np.add(bars1, bars2).tolist()
r = np.arange(0,len(pst.index))
 
names = pst.index
barWidth = 1
 
# Create red bars
plt.bar(r, bars1, color='red', edgecolor='white')
# Create green bars (middle), on top of the firs ones
plt.bar(r, bars2, bottom=bars1, color='green', edgecolor='white')
# Create blue bars (top)
plt.bar(r, bars3, bottom=bars, color='blue', edgecolor='white')
 
plt.xticks(r, names,rotation=90)
plt.xlabel('States',fontsize=12)
plt.ylabel('Percentage contribution to GDP',fontsize=12)
plt.title('Percentage contribution of the Primary, Secondary and Tertiary sectors as a percentage of the total GDP for all the states')

plt.legend(legends)

plt.tight_layout()
In [153]:
gdp_per_capita
Out[153]:
GDP per capita
Bihar 33954
Uttar Pradesh 49450
Assam 60621
Jharkhand 62091
Madhya Pradesh 62989
Odisha 73979
Meghalaya 76228.0
Tripura 77358.0
Rajasthan 84837
Chhatisgarh 86860
Nagaland 89607
Mizoram 97687
Andhra Pradesh 104977
Arunachal Pradesh 112718
Punjab 126606
Telangana 139035
Gujarat 141263.0
Karnataka 145141
Tamil Nadu 146503.0
Himachal Pradesh 147330
Maharashtra 152853
Uttrakhand 153076.0
Kerala 154778.0
Haryana 164077.0
Sikkim 240274
Goa 271793
In [154]:
C1 = gdp_per_capita[gdp_per_capita['GDP per capita'] > gdp_per_capita['GDP per capita'].quantile(0.85)]
C1
Out[154]:
GDP per capita
Kerala 154778.0
Haryana 164077.0
Sikkim 240274
Goa 271793
In [155]:
C2 = gdp_per_capita[(gdp_per_capita['GDP per capita'] > gdp_per_capita['GDP per capita'].quantile(0.50)) & (gdp_per_capita['GDP per capita'] < gdp_per_capita['GDP per capita'].quantile(0.85))]
C2
Out[155]:
GDP per capita
Arunachal Pradesh 112718
Punjab 126606
Telangana 139035
Gujarat 141263.0
Karnataka 145141
Tamil Nadu 146503.0
Himachal Pradesh 147330
Maharashtra 152853
Uttrakhand 153076.0
In [156]:
C3 = gdp_per_capita[(gdp_per_capita['GDP per capita'] > gdp_per_capita['GDP per capita'].quantile(0.20)) & (gdp_per_capita['GDP per capita'] <= gdp_per_capita['GDP per capita'].quantile(0.50))]
C3
Out[156]:
GDP per capita
Meghalaya 76228.0
Tripura 77358.0
Rajasthan 84837
Chhatisgarh 86860
Nagaland 89607
Mizoram 97687
Andhra Pradesh 104977
In [157]:
C4 = gdp_per_capita[gdp_per_capita['GDP per capita'] < gdp_per_capita['GDP per capita'].quantile(0.20)]
C4
Out[157]:
GDP per capita
Bihar 33954
Uttar Pradesh 49450
Assam 60621
Jharkhand 62091
Madhya Pradesh 62989
In [159]:
C1_df = df_final[['S.No.','Item']+list(states for states in C1.index)]
C2_df = df_final[['S.No.','Item']+list(states for states in C2.index)]
C3_df = df_final[['S.No.','Item']+list(states for states in C3.index)]
C4_df = df_final[['S.No.','Item']+list(states for states in C4.index)]
In [160]:
C1_df.reset_index(drop=True, inplace=True)
C2_df.reset_index(drop=True, inplace=True)
C3_df.reset_index(drop=True, inplace=True)
C4_df.reset_index(drop=True, inplace=True)
In [161]:
C1_df
Out[161]:
S.No. Item Kerala Haryana Sikkim Goa
0 1 Agriculture, forestry and fishing 5930617.0 8015238.0 137447 308507
1 1.1 Crops 3070386.0 4636731.0 114976 140421
2 1.2 Livestock 1656104.0 2916173.0 17338 30141
3 1.3 Forestry and logging 499808.0 352254.0 4529 15744
4 1.4 Fishing and aquaculture 704319.0 110080.0 604 122201
5 2 Mining and quarrying 558824.0 25186.0 1329 3622
6 Total Primary 6489442.0 8040424.0 138776 312129
7 3 Manufacturing 4273567.0 7756921.0 550697 1177608
8 4 Electricity, gas, water supply & other utility... 482470.0 1101919.0 212499 204110
9 5 Construction 7314003.0 3702571.0 82058 165819
10 Total Secondary 12070040.0 12561411.0 845253 1547536
11 6 Trade, repair, hotels and restaurants 8557345.0 4986319.0 70568 380927
12 6.1 Trade & repair services NaN 4817784.0 64624 343492
13 6.2 Hotels & restaurants 793498.0 168535.0 5945 37434
14 7 Transport, storage, communication & services r... 4020934.0 2560623.0 47347 189656
15 7.1 Railways 147897.0 423873.0 0 15649
16 7.2 Road transport NaN 1452364.0 35283 46171
17 7.3 Water transport 26956.0 NaN 0 17820
18 7.4 Air transport 125029.0 NaN 0 46359
19 7.5 Services incidental to transport 71567.0 190269.0 0 19272
20 7.6 Storage 3290.0 14459.0 0 357
21 7.7 Communication & services related to broadcasting 884767.0 479658.0 12064 44028
22 8 Financial services 2010306.0 1671486.0 21079 233618
23 9 Real estate, ownership of dwelling & professio... 7287633.0 6970183.0 75330 407099
24 10 Public administration 2068915.0 1036377.0 119514 346486
25 11 Other services 5728645.0 2001581.0 149265 180431
26 Total Tertiary 29673778.0 19226568.0 483103 1738217
27 12 TOTAL GSVA at basic prices 48233259.0 39828404.0 1467133 3597882
28 13 Taxes on Products 5189352.0 4985670.0 72200 527279
29 14 Subsidies on products 822381.0 1067867.0 18400 61854
30 15 Gross State Domestic Product 52600230.0 43746207.0 1520933 4063307
31 16 Population ('00) 339843.0 266620.0 6330 14950
32 17 Per Capita GSDP (Rs.) 154778.0 164077.0 240274 271793
In [162]:
C1_df['Total for all states'] = C1_df['Kerala']+C1_df['Haryana']+C1_df['Sikkim']+C1_df['Goa']
C1_df['Percentage of Total GDP'] = C1_df['Total for all states']/C1_df['Total for all states'][11] * 100
C1_df
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3086606009.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C1_df['Total for all states'] = C1_df['Kerala']+C1_df['Haryana']+C1_df['Sikkim']+C1_df['Goa']
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3086606009.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C1_df['Percentage of Total GDP'] = C1_df['Total for all states']/C1_df['Total for all states'][11] * 100
Out[162]:
S.No. Item Kerala Haryana Sikkim Goa Total for all states Percentage of Total GDP
0 1 Agriculture, forestry and fishing 5930617.0 8015238.0 137447 308507 14391809.0 102.834194
1 1.1 Crops 3070386.0 4636731.0 114976 140421 7962514.0 56.894773
2 1.2 Livestock 1656104.0 2916173.0 17338 30141 4619756.0 33.009671
3 1.3 Forestry and logging 499808.0 352254.0 4529 15744 872335.0 6.233120
4 1.4 Fishing and aquaculture 704319.0 110080.0 604 122201 937204.0 6.696630
5 2 Mining and quarrying 558824.0 25186.0 1329 3622 588961.0 4.208319
6 Total Primary 6489442.0 8040424.0 138776 312129 14980771.0 107.042521
7 3 Manufacturing 4273567.0 7756921.0 550697 1177608 13758793.0 98.311087
8 4 Electricity, gas, water supply & other utility... 482470.0 1101919.0 212499 204110 2000998.0 14.297787
9 5 Construction 7314003.0 3702571.0 82058 165819 11264451.0 80.488196
10 Total Secondary 12070040.0 12561411.0 845253 1547536 27024240.0 193.097056
11 6 Trade, repair, hotels and restaurants 8557345.0 4986319.0 70568 380927 13995159.0 100.000000
12 6.1 Trade & repair services NaN 4817784.0 64624 343492 NaN NaN
13 6.2 Hotels & restaurants 793498.0 168535.0 5945 37434 1005412.0 7.183998
14 7 Transport, storage, communication & services r... 4020934.0 2560623.0 47347 189656 6818560.0 48.720847
15 7.1 Railways 147897.0 423873.0 0 15649 587419.0 4.197301
16 7.2 Road transport NaN 1452364.0 35283 46171 NaN NaN
17 7.3 Water transport 26956.0 NaN 0 17820 NaN NaN
18 7.4 Air transport 125029.0 NaN 0 46359 NaN NaN
19 7.5 Services incidental to transport 71567.0 190269.0 0 19272 281108.0 2.008609
20 7.6 Storage 3290.0 14459.0 0 357 18106.0 0.129373
21 7.7 Communication & services related to broadcasting 884767.0 479658.0 12064 44028 1420517.0 10.150060
22 8 Financial services 2010306.0 1671486.0 21079 233618 3936489.0 28.127505
23 9 Real estate, ownership of dwelling & professio... 7287633.0 6970183.0 75330 407099 14740245.0 105.323884
24 10 Public administration 2068915.0 1036377.0 119514 346486 3571292.0 25.518052
25 11 Other services 5728645.0 2001581.0 149265 180431 8059922.0 57.590785
26 Total Tertiary 29673778.0 19226568.0 483103 1738217 51121666.0 365.281066
27 12 TOTAL GSVA at basic prices 48233259.0 39828404.0 1467133 3597882 93126678.0 665.420650
28 13 Taxes on Products 5189352.0 4985670.0 72200 527279 10774501.0 76.987343
29 14 Subsidies on products 822381.0 1067867.0 18400 61854 1970502.0 14.079883
30 15 Gross State Domestic Product 52600230.0 43746207.0 1520933 4063307 101930677.0 728.328110
31 16 Population ('00) 339843.0 266620.0 6330 14950 627743.0 4.485430
32 17 Per Capita GSDP (Rs.) 154778.0 164077.0 240274 271793 830922.0 5.937210
In [163]:
C1_contributor = C1_df[['Item','Percentage of Total GDP']][:-2].sort_values(by='Percentage of Total GDP', ascending=False)
C1_contributor.reset_index(drop=True, inplace=True)
C1_contributor['Cumulative sum'] = C1_contributor['Percentage of Total GDP'].cumsum()
C1_contributor
Out[163]:
Item Percentage of Total GDP Cumulative sum
0 Gross State Domestic Product 728.328110 728.328110
1 TOTAL GSVA at basic prices 665.420650 1393.748760
2 Tertiary 365.281066 1759.029826
3 Secondary 193.097056 1952.126882
4 Primary 107.042521 2059.169403
5 Real estate, ownership of dwelling & professio... 105.323884 2164.493287
6 Agriculture, forestry and fishing 102.834194 2267.327481
7 Trade, repair, hotels and restaurants 100.000000 2367.327481
8 Manufacturing 98.311087 2465.638568
9 Construction 80.488196 2546.126764
10 Taxes on Products 76.987343 2623.114107
11 Other services 57.590785 2680.704892
12 Crops 56.894773 2737.599666
13 Transport, storage, communication & services r... 48.720847 2786.320513
14 Livestock 33.009671 2819.330184
15 Financial services 28.127505 2847.457689
16 Public administration 25.518052 2872.975741
17 Electricity, gas, water supply & other utility... 14.297787 2887.273528
18 Subsidies on products 14.079883 2901.353411
19 Communication & services related to broadcasting 10.150060 2911.503471
20 Hotels & restaurants 7.183998 2918.687469
21 Fishing and aquaculture 6.696630 2925.384099
22 Forestry and logging 6.233120 2931.617218
23 Mining and quarrying 4.208319 2935.825538
24 Railways 4.197301 2940.022839
25 Services incidental to transport 2.008609 2942.031448
26 Storage 0.129373 2942.160821
27 Trade & repair services NaN NaN
28 Road transport NaN NaN
29 Water transport NaN NaN
30 Air transport NaN NaN
In [164]:
plt.figure(figsize=(6,4), dpi=600)
sns.barplot(y=C1_contributor['Item'], x = C1_contributor['Percentage of Total GDP'], palette='inferno')
plt.xlabel("Percentage of Total GSDP for C1 States")
plt.ylabel('Sub-sectors')
plt.title('Percentage of Total GSDP for C1 States vs Sub-sectors')
plt.savefig("Percentage of Total GSDP for C1 States vs Sub-sectors.png", bbox_inches='tight', dpi=600)

plt.show()
In [165]:
C2_df['Total for all states']=list(C2_df[list(states for states in C2_df.columns)[2:]].sum(axis=1))
C2_df['Percentage of Total GDP'] = C2_df['Total for all states']/C2_df['Total for all states'][11] * 100
C2_contributor = C2_df[['Item','Percentage of Total GDP']][:-2].sort_values(by='Percentage of Total GDP', ascending=False)
C2_contributor.reset_index(drop=True, inplace=True)
C2_contributor['Cumulative sum'] = C2_contributor['Percentage of Total GDP'].cumsum()
C2_contributor
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3546390381.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C2_df['Total for all states']=list(C2_df[list(states for states in C2_df.columns)[2:]].sum(axis=1))
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3546390381.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C2_df['Percentage of Total GDP'] = C2_df['Total for all states']/C2_df['Total for all states'][11] * 100
Out[165]:
Item Percentage of Total GDP Cumulative sum
0 Gross State Domestic Product 957.529962 957.529962
1 TOTAL GSVA at basic prices 861.355113 1818.885075
2 Tertiary 454.332791 2273.217866
3 Secondary 267.270597 2540.488463
4 Manufacturing 178.312474 2718.800937
5 Real estate, ownership of dwelling & professio... 150.429716 2869.230653
6 Primary 139.751730 3008.982383
7 Agriculture, forestry and fishing 122.812573 3131.794956
8 Taxes on Products 117.412440 3249.207396
9 Trade, repair, hotels and restaurants 100.000000 3349.207396
10 Trade & repair services 90.224299 3439.431695
11 Crops 77.646928 3517.078622
12 Construction 66.385234 3583.463857
13 Financial services 59.270602 3642.734458
14 Other services 59.200409 3701.934868
15 Transport, storage, communication & services r... 55.111749 3757.046617
16 Livestock 31.620266 3788.666883
17 Public administration 30.320314 3818.987196
18 Road transport 24.247676 3843.234873
19 Electricity, gas, water supply & other utility... 22.572885 3865.807758
20 Subsidies on products 21.237591 3887.045349
21 Mining and quarrying 16.939155 3903.984504
22 Communication & services related to broadcasting 15.364200 3919.348704
23 Hotels & restaurants 9.775698 3929.124401
24 Forestry and logging 9.149767 3938.274168
25 Fishing and aquaculture 4.395611 3942.669779
26 Railways 4.073423 3946.743202
27 Services incidental to transport 2.833433 3949.576635
28 Air transport 1.077487 3950.654122
29 Storage 0.601767 3951.255889
30 Water transport 0.519592 3951.775480
In [166]:
plt.figure(figsize=(6,4), dpi=600)
sns.barplot(y=C2_contributor['Item'], x = C2_contributor['Percentage of Total GDP'],palette='hot')
plt.xlabel("Percentage of Total GSDP for C2 States")
plt.ylabel('Sub-sectors')
plt.title('Percentage of Total GSDP for C2 States vs Sub-sectors')
plt.show()
In [167]:
C3_df['Total for all states']=list(C3_df[list(states for states in C3_df.columns)[2:]].sum(axis=1))
C3_df['Percentage of Total GDP'] = C3_df['Total for all states']/C3_df['Total for all states'][11] * 100
C3_contributor = C3_df[['Item','Percentage of Total GDP']][:-2].sort_values(by='Percentage of Total GDP', ascending=False)
C3_contributor.reset_index(drop=True, inplace=True)
C3_contributor['Cumulative sum'] = C3_contributor['Percentage of Total GDP'].cumsum()
C3_contributor
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3224460790.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C3_df['Total for all states']=list(C3_df[list(states for states in C3_df.columns)[2:]].sum(axis=1))
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\3224460790.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C3_df['Percentage of Total GDP'] = C3_df['Total for all states']/C3_df['Total for all states'][11] * 100
Out[167]:
Item Percentage of Total GDP Cumulative sum
0 Gross State Domestic Product 1034.136202 1034.136202
1 TOTAL GSVA at basic prices 974.535729 2008.671931
2 Tertiary 425.330004 2434.001934
3 Primary 312.529255 2746.531189
4 Agriculture, forestry and fishing 254.004929 3000.536119
5 Secondary 236.676463 3237.212582
6 Crops 136.875835 3374.088417
7 Manufacturing 115.524874 3489.613291
8 Trade, repair, hotels and restaurants 100.000000 3589.613291
9 Taxes on Products 99.120409 3688.733700
10 Real estate, ownership of dwelling & professio... 98.436763 3787.170463
11 Construction 94.393851 3881.564314
12 Trade & repair services 92.698553 3974.262867
13 Other services 74.311839 4048.574706
14 Livestock 73.408993 4121.983698
15 Transport, storage, communication & services r... 72.344253 4194.327952
16 Mining and quarrying 58.524312 4252.852263
17 Public administration 46.886119 4299.738382
18 Subsidies on products 39.519936 4339.258318
19 Road transport 39.010677 4378.268995
20 Financial services 33.351029 4411.620024
21 Electricity, gas, water supply & other utility... 26.757753 4438.377777
22 Forestry and logging 23.088031 4461.465807
23 Fishing and aquaculture 20.632064 4482.097871
24 Communication & services related to broadcasting 17.996022 4500.093894
25 Railways 7.439935 4507.533829
26 Hotels & restaurants 7.301454 4514.835283
27 Services incidental to transport 5.909872 4520.745155
28 Water transport 0.674891 4521.420046
29 Storage 0.373999 4521.794045
30 Air transport 0.309427 4522.103472
In [168]:
plt.figure(figsize=(6,4), dpi=600)
sns.barplot(y=C3_contributor['Item'], x = C3_contributor['Percentage of Total GDP'], palette='autumn')
plt.xlabel("Percentage of Total GSDP for C3 States")
plt.ylabel('Sub-sectors')
plt.title('Percentage of Total GSDP for C3 States vs Sub-sectors')

plt.show()
In [169]:
C4_df['Total for all states']=list(C4_df[list(states for states in C4_df.columns)[2:]].sum(axis=1))
C4_df['Percentage of Total GDP'] = C4_df['Total for all states']/C4_df['Total for all states'][11] * 100
C4_contributor = C4_df[['Item','Percentage of Total GDP']][:-2].sort_values(by='Percentage of Total GDP', ascending=False)
C4_contributor.reset_index(drop=True, inplace=True)
C4_contributor['Cumulative sum'] = C4_contributor['Percentage of Total GDP'].cumsum()
C4_contributor
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\791793354.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C4_df['Total for all states']=list(C4_df[list(states for states in C4_df.columns)[2:]].sum(axis=1))
C:\Users\cheta\AppData\Local\Temp\ipykernel_33516\791793354.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  C4_df['Percentage of Total GDP'] = C4_df['Total for all states']/C4_df['Total for all states'][11] * 100
Out[169]:
Item Percentage of Total GDP Cumulative sum
0 Gross State Domestic Product 850.234400 850.234400
1 TOTAL GSVA at basic prices 800.863184 1651.097584
2 Tertiary 380.971605 2032.069190
3 Primary 229.406867 2261.476057
4 Agriculture, forestry and fishing 207.011384 2468.487441
5 Secondary 190.484708 2658.972149
6 Crops 143.652127 2802.624276
7 Trade, repair, hotels and restaurants 100.000000 2902.624276
8 Trade & repair services 93.042143 2995.666419
9 Manufacturing 91.609199 3087.275618
10 Real estate, ownership of dwelling & professio... 88.231990 3175.507608
11 Construction 83.142536 3258.650144
12 Taxes on Products 80.193985 3338.844129
13 Transport, storage, communication & services r... 59.078259 3397.922389
14 Other services 57.090911 3455.013299
15 Public administration 48.452443 3503.465742
16 Livestock 43.443084 3546.908826
17 Subsidies on products 30.822770 3577.731596
18 Road transport 28.450103 3606.181698
19 Financial services 28.118003 3634.299702
20 Mining and quarrying 22.395483 3656.695185
21 Communication & services related to broadcasting 16.238468 3672.933653
22 Electricity, gas, water supply & other utility... 15.732973 3688.666625
23 Forestry and logging 13.326865 3701.993491
24 Railways 12.141441 3714.134932
25 Hotels & restaurants 6.957857 3721.092788
26 Fishing and aquaculture 6.589304 3727.682093
27 Services incidental to transport 1.002114 3728.684207
28 Storage 0.815307 3729.499514
29 Air transport 0.403598 3729.903112
30 Water transport 0.027225 3729.930337
In [170]:
plt.figure(figsize=(6,4), dpi=600)
sns.barplot(y=C4_contributor['Item'], x = C4_contributor['Percentage of Total GDP'], palette='spring')
plt.xlabel("Percentage of Total GSDP for C4 States")
plt.ylabel('Sub-sectors')
plt.title('Percentage of Total GSDP for C4 States vs Sub-sectors')

plt.show()
In [ ]: